//
//  baseTableViewController.swift
//  新浪微博
//
//  Created by yzl on 15/7/28.
//  Copyright © 2015年 yjc. All rights reserved.
//

import UIKit

class baseTableViewController: UITableViewController, VisitorLoginViewDelegate {  /// 用户登录标记
      var Userlogin = userAccount.userLogin
/// 基类拥有代理属性
    var visitorView: VisitorLoginView?
    override func loadView() {
/// 根据用户是否登录判断是否替换根视图
        Userlogin ?super.loadView() : setupVisitorLoginView()
    }
/// 设置访客视图
    private func setupVisitorLoginView() {
        // 初始化视图
        visitorView = VisitorLoginView()
        // 设置代理
        visitorView?.delegate = self
        view = visitorView
/// 设置访客视图的状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
    }
//    private func setVistorView(){
//        view = UIView()
//    }
    // MARK: - VisitorLoginViewDelegate,实现代理方法
    func visitorLoginViewWillLogin() {
      let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
        print("登录")
    }
    func visitorLoginViewWillRegister() {
        print("注册")
    }
}